<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="EmployModalTitle" aria-hidden="true" style="display: none;" id="EmployModal">
    <div class="modal-dialog modal-lg" style="margin-top:2%;">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="EmployModalTitle">雇用</h4>
            </div>
            <div class="modal-body">
                
                <div class="databox databox-xlg databox-halved radius-bordered databox-shadowed databox-vertical">
                    <div class="databox-top bg-white padding-10">
                        <div class="col-lg-4 col-sm-4 col-xs-4">
                            <img class="image-circular bordered-3 bordered-palegreen" style="width:75px; height:75px;" id="EmployPicture" src="">
                        </div>
                        <div class="col-lg-8 col-sm-8 col-xs-8 text-align-left padding-10">
                            <span class="databox-header carbon no-margin" id="EmploySubject"></span>
                            <span class="databox-text lightcarbon no-margin" id="EmployDescribe"></span>
                        </div>
                    </div>
                    <div class="databox-bottom bg-white no-padding">
                        <div class="databox-row row-12">
                            <div class="databox-row row-6 no-padding">
                                <div class="databox-cell cell-4 no-padding text-align-center bordered-right bordered-platinum">
                                    <span class="databox-text sonic-silver  no-margin" id="EmployFollow"></span>
                                    <span class="databox-number lightcarbon no-margin" id="EmployFollowNum">0</span>
                                </div>
                                <div class="databox-cell cell-4 no-padding text-align-center bordered-right bordered-platinum">
                                    <span class="databox-text sonic-silver no-margin" id="EmployFavorites"></span>
                                    <span class="databox-number lightcarbon no-margin" id="EmployFavoritesNum">0</span>
                                </div>
                                <div class="databox-cell cell-4 no-padding text-align-center">
                                    <span class="databox-text sonic-silver no-margin" id="EmploySell"></span>
                                    <span class="databox-number lightcarbon no-margin" id="EmploySellNum">0</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
                <h5>输入您购买的预算</h5>
                <input type="text" id="EmployMoney" class="form-control" placeholder="价格" style="width:200px;">
                <h5>手机号码</h5>
                <input type="text" id="EmployPhone" class="form-control" placeholder="联系电话" style="width:200px;">
                
                 <h4>详细描述需求：</h4>
                
                {template Public:Page:umeditor}
                
                
                <textarea id="EmployContent" name="content" style="width:870px;height:150px;"></textarea>
                <input id="EmployUid" type="hidden" value="0" />
                <input id="Employid" type="hidden" value="0" />
              
            </div>
            
            <div class="row">
            <div class="col-lg-12" style="padding-right:40px;">
            <div class="form-group text-right">
            <button class="btn btn-default" type="button" data-bb-handler="cancel" onclick="$('#EmployModal').modal('hide');">取消</button> <button class="btn btn-primary" type="button" data-bb-handler="confirm" id="SubmitEmploy" onclick="SubmitEmploy()">提交</button></div></div>
            </div>
        </div>
    </div>
</div>
    
<script>							
$(function(){
	var um = UM.getEditor('EmployContent');
	 um.addListener("contentChange",function(){
		if(UM.getEditor('EmployContent').hasContents()){
			$('#SubmitEmploy').attr('disabled',false);
		}
	 });
})
function Employ(uid,id){
	
	bootbox.hideAll();
	if(uid && id){
		var title='购买服务';
	}else{
		var title='雇用服务商';
		id=0
	}

	$('#EmployUid').val(uid);
	$('#Employid').val(id);
	
	$('#EmployModalTitle').html(title);
			
	$('#EmployModal').modal();

	$.getJSON('/get/employ/event/uid/'+uid+'/id/'+id, function(json){
		if(json.status=='ok'){
			
			var employform='';
			
			if(json.data.id){
				 $('#EmployMoney').val(json.data.money);
				 $('#EmploySubject').html(json.data.subject);
				 $('#EmployPicture').attr('src',SURL+'/'+json.data.picture);
				 $('#EmployDescribe').html(json.data.category_name_1+' '+json.data.category_name_2+' '+json.data.category_name_3);
				 $('#EmployFollow').html('关注');
				 $('#EmployFollowNum').html(json.data.show_number);
				 $('#EmployFavorites').html('收藏');
				 $('#EmployFavoritesNum').html(json.data.favorites_number);
				 $('#EmploySell').html('出售');
				 $('#EmploySellNum').html(json.data.sell_number);
			}
			
			if(json.data.moneyin>=0 && !json.data.id){
				$('#EmploySubject').html(json.data.username);
				if(json.data.provname && json.data.cityname && json.data.distname){
					$('#EmployDescribe').html(json.data.provname+' '+json.data.cityname+' '+json.data.distname);
				}else{
					$('#EmployDescribe').html('城市未填');
				}
				 $('#EmployPicture').attr('src',SURL+$(json.data.picture).attr('src'));
				 $('#EmployFollow').html('收入');
				 $('#EmployFollowNum').html(json.data.moneyin/100);
				 $('#EmployFavorites').html('投稿');
				 $('#EmployFavoritesNum').html(json.data.draft_number);
				 $('#EmploySell').html('中标');
				 $('#EmploySellNum').html(json.data.success_number);
			}
			

			return false; 

		}
		bootbox.hideAll();
	});		
	
}

function SubmitEmploy(){
	var money=$('#EmployMoney').val();
	var phone=$('#EmployPhone').val();
	
	if(isNaN(parseInt(money)) && !parseInt(money)){
		alert('请输入购买金额！');
		return false; 
	}
	
	if(isNaN(parseInt(phone)) && !parseInt(phone)){
		alert('请输入手机号码！');
		return false; 
	}
	
	
	 if(!UM.getEditor('EmployContent').hasContents()){
		 alert('请填写购买需求！');
		 return false; 
	 }
	 
	 var content=UM.getEditor('EmployContent').getContent();
	 
	var uid=$('#EmployUid').val();
	var id=$('#Employid').val();
				 
	bootbox.confirm({  
	   buttons: {  
		  confirm: {  
			 label: '确认',  
		  },  
		  cancel: {  
			 label: '取消',  
		  }  
	   },  
	   title:'提示',
	   message: '<i class="glyphicon glyphicon-warning-sign"></i> 您确认要支付'+money+'元?',  
		   callback: function(result) {  
			  if(result) {  
				 bootbox.hideAll();
				 
				 $.post('{echo U("/post/employ/buy")}',{id:id,uid:uid,money:money,phone:phone,content:content}, function(json) {
							
						$('.bootbox').PhpappProgress({json:json});

						return true;
							
				 }, 'json');
				 
				  bootbox.dialog({
						 message: '<div class="progress progress-striped active"><div style="width: 1%" aria-valuemax="100" aria-valuemin="0" aria-valuenow="20" role="progressbar" class="progress-bar progress-bar-info"><span>0%</span></div></div>',
						 title: '<i class="icon fa fa-retweet"></i> 提交中',
						 closeButton: false
				 }).PhpappProgress({time:5000});
			 
				  return false; 
	  
			  }
		   } 

	})
   
	return false;
		
}

</script>

 